import 'package:freezed_annotation/freezed_annotation.dart';

part 'project_response.freezed.dart';

part 'project_response.g.dart';

@freezed
abstract class Project with _$Project {
  const factory Project({
    @Default(false) bool adminAdd,
    @Default('') String apkLink,
    @Default(0) int audit,
    @Default('') String author,
    @Default(false) bool canEdit,
    @Default(0) int chapterId,
    @Default('') String chapterName,
    @Default(false) bool collect,
    @Default(0) int courseId,
    @Default('') String desc,
    @Default('') String descMd,
    @Default('') String envelopePic,
    @Default(false) bool fresh,
    @Default('') String host,
    @Default(0) int id,
    @Default(false) bool isAdminAdd,
    @Default('') String link,
    @Default('') String niceDate,
    @Default('') String niceShareDate,
    @Default('') String origin,
    @Default('') String prefix,
    @Default('') String projectLink,
    @Default(0) int publishTime,
    @Default(0) int realSuperChapterId,
    @Default(0) int selfVisible,
    @Default(0) int shareDate,
    @Default('') String shareUser,
    @Default(0) int superChapterId,
    @Default('') String superChapterName,
    @Default([]) List<Tags> tags,
    @Default('') String title,
    @Default(0) int type,
    @Default(0) int userId,
    @Default(0) int visible,
    @Default(0) int zan,
  }) = _Project;

  factory Project.fromJson(Map<String, Object?> json) =>
      _$ProjectFromJson(json);
}

@freezed
abstract class Tags with _$Tags {
  const factory Tags({@Default('') String name, @Default('') String url}) =
      _Tags;

  factory Tags.fromJson(Map<String, Object?> json) => _$TagsFromJson(json);
}

class ProjectResponse {
  final int total;
  final List<Project> projects;

  const ProjectResponse({required this.total, required this.projects});

  @override
  String toString() {
    return 'ProjectResponse{total: $total, projects: $projects}';
  }
}
